#encoding=utf-8
import asyncio
from bilibili_api import video

# 实例化
r = video.VideoOnlineMonitor("BV1pg4y1b7dY")


# 装饰器方法注册事件监听器
@r.on("ONLINE")
async def handler(data):
    print(data['data']['room']['online'],'人')


# 函数方法注册事件监听器
async def handler2(data):
    print(data)
    r.add_event_listener("ONLINE", handler2)

asyncio.get_event_loop().run_until_complete(r.connect())